#include <stdio.h>

unsigned main(unsigned x,int k){
    
    scanf("%d %d",&x,&k);
    unsigned xsra = (int) x>>k;
    int w = 8*sizeof(x);
    printf("%d", ((1u << (w-k))-1)& xsra);
    return 0;
}

